﻿ 
using NUnit.Framework;

namespace CSSpec.Tests
{
    [TestFixture]
    public class GivenWhenThenFixtureFixture : CSSpecFixture<object>
    {
        [Test]
        public void GivenWhenThen_PersistsStateAndInvokesMethods()
        {
            object expectedState = null;
            var givenCallCount = 0;
            var whenCallCount = 0;
            var thenCallCount = 0;

            Given(testState =>
                      {
                          givenCallCount++;
                          expectedState = testState;  
                      })
                .When(testState =>
                          {
                              whenCallCount++;
                              testState.ShouldEqual(expectedState); 
                          })
                .Then(testState =>
                          {
                              thenCallCount++;
                              testState.ShouldEqual(expectedState);
                          }); 

            expectedState.ShouldNotBeNull();

            givenCallCount.ShouldEqualOne();
            whenCallCount.ShouldEqualOne();
            thenCallCount.ShouldEqualOne();
        }
    }
}
